//
//  HeaderModel.m
//  budejiePersonalPage
//
//  Created by 李叶夫 on 16/8/30.
//  Copyright © 2016年 李叶夫. All rights reserved.
//api/api_open.php?a=profile&appname=bs0315&asid=C00B1CA2-C583-4BE8-B6CC-FC0663754D82&c=user&client=iphone&device=ios%20device&from=ios&jbk=0&mac=&market=&openudid=d41d8cd98f00b204e9800998ecf8427e52d872f9&udid=&userid=13930724&ver=4.3


#import "HeaderModel.h"
#import "HeaderNetWorkTool.h"

#define URLSTR @"api/api_open.php"

@implementation HeaderModel

+ (instancetype)headerModelWithDic:(NSDictionary *)dic
{
    HeaderModel *model = [HeaderModel new];
    
    [model setValuesForKeysWithDictionary:dic];
    
    return model;
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    
}



+ (void)loadDataWithUid:(NSString *)uid successBlock:(void (^)(HeaderModel *))successBlock failBlock:(void (^)(NSError *))failBlock
{
    NSDictionary *parameters = @{
        @"a":@"profile",
        @"appname":@"bs0315",
        @"asid":@"C00B1CA2-C583-4BE8-B6CC-FC0663754D82",
        @"c":@"user",
        @"client":@"iphone",
        @"device":@"ios%20device",
        @"from":@"ios",
        @"jbk":@"0",
        @"mac":@"",
        @"market":@"",
        @"openudid":@"d41d8cd98f00b204e9800998ecf8427e52d872f9",
        @"udid":@"",
        @"userid":uid,
        @"ver":@"4.3",
    };
    
    [[HeaderNetWorkTool sharedHeaderNetWorkTool] GET:URLSTR parameters:parameters progress:nil success:^(NSURLSessionDataTask * _Nonnull task, NSDictionary *responseObject) {
        
//        NSLog(@"responseObject:%@",responseObject);
        NSDictionary *dic = responseObject[@"data"];
        HeaderModel *model = [HeaderModel headerModelWithDic:dic];
        if (successBlock) {
            successBlock(model);
        }
        
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
        if (failBlock) {
            failBlock(error);
        }
    }];
    
    
    
    
}


@end
